package BlogMybatis.blog.mapper;

import BlogMybatis.blog.pojo.Comment;
import com.baomidou.mybatisplus.core.mapper.BaseMapper;
import org.apache.ibatis.annotations.Param;

import java.util.List;

/**
 * <p>
 *  Mapper 接口
 * </p>
 *
 * @author Brandt
 * @since 2020-06-07
 */
public interface CommentMapper extends BaseMapper<Comment> {

    //根据博客查找父级评论id为空的评论，即查找父级评论
    List<Comment> findByBlogIdParentIdNull(@Param("blogId") Long blogId,@Param("blogParentId") Long blogParentId);

    //查找一级回复
    List<Comment> findByBlogIdParentIdNotNull(@Param("blogId") Long blogId,@Param("id") Long id);

    //查找二级回复
    List<Comment> findByBlogIdAndReplayId(@Param("blogId") Long blogId,@Param("childId") Long childId);

    int saveComments(Comment comment);

}
